################################################################################
#
# dolphin-triforce
#
################################################################################
# Version: Nov 29, 2024
DOLPHIN_TRIFORCE_VERSION = 99bc5987122d1f3b2b2bbf14c3d639f909ad556c
DOLPHIN_TRIFORCE_SITE = https://crediar.dev/crediar/dolphin
DOLPHIN_TRIFORCE_SITE_METHOD = git
DOLPHIN_TRIFORCE_LICENSE = GPLv2+
DOLPHIN_TRIFORCE_GIT_SUBMODULES = YES
DOLPHIN_TRIFORCE_SUPPORTS_IN_SOURCE_BUILD = NO

DOLPHIN_TRIFORCE_DEPENDENCIES += bluez5_utils ffmpeg hidapi host-xz libcurl
DOLPHIN_TRIFORCE_DEPENDENCIES += libevdev libpng libusb lzo sdl2 speex xz zlib

ifeq ($(BR2_PACKAGE_QT6),y)
DOLPHIN_TRIFORCE_DEPENDENCIES += qt6base qt6svg
endif

DOLPHIN_TRIFORCE_CONF_OPTS  = -DCMAKE_BUILD_TYPE=Release
DOLPHIN_TRIFORCE_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DCMAKE_CXX_FLAGS=-DIMGUI_DEFINE_MATH_OPERATORS
DOLPHIN_TRIFORCE_CONF_OPTS += -DDISTRIBUTOR='batocera.linux'
DOLPHIN_TRIFORCE_CONF_OPTS += -DUSE_DISCORD_PRESENCE=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DUSE_MGBA=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DUSE_UPNP=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_TESTS=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_AUTOUPDATE=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_ANALYTICS=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_SDL=ON
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_CLI_TOOL=OFF
DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_NOGUI=OFF

ifeq ($(BR2_PACKAGE_XORG7),y)
    DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_X11=ON
else
    DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_X11=OFF
endif

ifeq ($(BR2_PACKAGE_VULKAN_HEADERS)$(BR2_PACKAGE_VULKAN_LOADER),yy)
    DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_VULKAN=ON
else
    DOLPHIN_TRIFORCE_CONF_OPTS += -DENABLE_VULKAN=OFF
endif

ifeq ($(BR2_PACKAGE_SPEEXDSP),y)
    DOLPHIN_TRIFORCE_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS="-lspeexdsp"
endif

define DOLPHIN_TRIFORCE_INI
    mkdir -p $(TARGET_DIR)/usr/share/triforce
    # copy extra ini files
    cp -prn $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/emulators/dolphin-triforce/*.ini \
		$(TARGET_DIR)/usr/share/triforce
endef

DOLPHIN_TRIFORCE_POST_INSTALL_TARGET_HOOKS += DOLPHIN_TRIFORCE_INI

$(eval $(cmake-package))
